<%@ Control Language="C#" ClassName="State_Group_Access" Inherits="Dimok.Web.UI.TableControl" %>
<%@ Register Namespace="Dimok.Web.UI"  Assembly="Dimok.Web.UI" TagPrefix="OR"  %>
<%@ Register Namespace="Data.DataSources" Assembly="App_Code" TagPrefix="DS"  %>

<script runat="server">
</script>

<asp:UpdatePanel ID="pnlRebateOffers" UpdateMode="Always" runat="server">
	<ContentTemplate>
		<OR:GridViewEx ID="grv" runat="server" AutoGenerateColumns="False" DataSourceID="ds"
			ShowFooter="True" AllowSorting="True" BackColor="Window" CellPadding="0" EnableTheming="True"
			Font-Names="verdana" EnableViewState="False" DataKeyNames="StateID,principal_id,StateAccessID"
			ViewNameUpdate="t_State_Group_Access" ViewNameInsert="t_State_Group_Access" DebugMode="true"
			>
			<Columns>

				<asp:TemplateField HeaderText="State" SortExpression="StateLong">
					<ItemTemplate><asp:Label Text='<%#Eval("StateLong") %>' runat="server" /></ItemTemplate>
					<EditItemTemplate>
						<asp:DropDownList ID="selStateID" DataSourceID="dsStates" DataTextField="NameLong" DataValueField="ID" runat="server"
								 SelectedValue='<%# Bind("StateID") %>' AppendDataBoundItems="true">
								 <asp:ListItem Text="Select ..." Value=""></asp:ListItem>
								 </asp:DropDownList>
					</EditItemTemplate>
					<FooterTemplate>
						<asp:DropDownList ID="StateID" DataSourceID="dsStates" DataTextField="NameLong" DataValueField="ID" runat="server"></asp:DropDownList>
					</FooterTemplate>
				</asp:TemplateField>

				<asp:TemplateField HeaderText="GroupName" SortExpression="GroupName">
					<ItemTemplate><%#Eval("GroupName") %></ItemTemplate>
					<EditItemTemplate><%#Eval("GroupName") %></EditItemTemplate>
					<FooterTemplate>
						<asp:DropDownList ID="principal_id" DataSourceID="dsGroups" DataTextField="Name" DataValueField="Name" runat="server"></asp:DropDownList>
					</FooterTemplate>
				</asp:TemplateField>

				<asp:TemplateField HeaderText="StateAccess" SortExpression="StateAccess">
					<ItemTemplate><asp:Label Text='<%#Eval("StateAccess") %>' runat="server" /></ItemTemplate>
					<EditItemTemplate>
						<asp:DropDownList ID="selStateAccessID" DataSourceID="dsStateAccess" DataTextField="Name" DataValueField="ID" runat="server"
								 SelectedValue='<%# Bind("StateAccessID") %>'></asp:DropDownList>
					</EditItemTemplate>
					<FooterTemplate>
						<asp:DropDownList ID="StateAccessID" DataSourceID="dsStateAccess" DataTextField="Name" DataValueField="ID" runat="server"></asp:DropDownList>
					</FooterTemplate>
				</asp:TemplateField>

			</Columns>
		</OR:GridViewEx>
	</ContentTemplate>
</asp:UpdatePanel>

<DS:State_Group_AccessDataSource ID="ds" runat="server"></DS:State_Group_AccessDataSource>

<DS:StatesDataSource ID="dsStates" EmtyRowPolicy="OnlyIfEmpty" runat="server"></DS:StatesDataSource>

<DS:GroupsDataSource ID="dsGroups" runat="server"></DS:GroupsDataSource>

<DS:StatesAccessDataSource ID="dsStateAccess" runat="server"></DS:StatesAccessDataSource>
